package session01;

import session01.Student;
import session01.Teacher;

public class Team {
    String teamNo;
    Student[] students;
    Teacher teacher;

    public Team() {
        students = new Student[3];
    }

    public void addTeacher(Teacher teacher) {
        this.teacher = teacher;
    }

    public void listTeacher() {
        //引用属性时最好加上this
        System.out.println("老师姓名：" + this.teacher.teacherName + "老师教的课程：" + this.teacher.course);
    }

    /**
     * 添加一个学生到班级
     *
     * @param s：一个学生对象
     * @param i：索引下标
     */
    public void addStudent(Student s, int i) {
        if (i < students.length) {
            students[i] = s;
        }
    }

    /**
     * 列出所有学生的信息，并执行学生的方法
     */
    public void listStudents() {
        String No = "";
        String Name = "";
        for (int i = 0; i < students.length; i++) {
            No = students[i].studentNo;
            Name = students[i].studentName;
            System.out.println("学号为：" + No + "学生姓名为：" + Name);
            students[i].learn();
            students[i].eat();
        }
    }
}
